package com.cskaoyan.search.entity;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;


@Document(indexName = "tb_item", type = "_doc", shards = 1, replicas = 0)
public class ItemDocument {
	// 改成员变量的值，会同时作为文档的唯一标识值 _id
	@Id
	private Long id;
	@Field(type = FieldType.Text)
	private String image;
	@Field(type = FieldType.Long)
	private Integer status;
	@Field(type = FieldType.Text,analyzer = "ik_max_word" )
	private String sellPoint;
	@Field(type = FieldType.Text,analyzer = "ik_max_word")
	private String title;
	@Field(type = FieldType.Long)
	private Integer num;
	@Field(type = FieldType.Long)
	private Long cid;
	@Field(type = FieldType.Date)
	private Date created;
	@Field(type = FieldType.Float)
	private Double price;
	@Field(type = FieldType.Long)
	private Integer limitNum;
	@Field(type = FieldType.Date)
	private Date updated;

	public void setCid(Long cid) {
		this.cid = cid;
	}

	@Override
	public String toString() {
		return "ItemDocument{" +
				"id=" + id +
				", image='" + image + '\'' +
				", status=" + status +
				", sellPoint='" + sellPoint + '\'' +
				", title='" + title + '\'' +
				", num=" + num +
				", cid=" + cid +
				", created=" + created +
				", price=" + price +
				", limitNum=" + limitNum +
				", updated=" + updated +
				'}';
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getImage(){
		if (image != null && !"".equals(image)) {
			String[] strings = image.split(",");
			return strings[0];
		}
		return null;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getSellPoint() {
		return sellPoint;
	}

	public void setSellPoint(String sellPoint) {
		this.sellPoint = sellPoint;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Integer getNum() {
		return num;
	}

	public void setNum(Integer num) {
		this.num = num;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Integer getLimitNum() {
		return limitNum;
	}

	public void setLimitNum(Integer limitNum) {
		this.limitNum = limitNum;
	}

	public Date getUpdated() {
		return updated;
	}

	public void setUpdated(Date updated) {
		this.updated = updated;
	}

}
